package generators;

import java.util.*;

public class TestSuiteGenerator
{
  protected static String nl;
  public static synchronized TestSuiteGenerator create(String lineSeparator)
  {
    nl = lineSeparator;
    TestSuiteGenerator result = new TestSuiteGenerator();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package tests.generated.";
  protected final String TEXT_2 = ";" + NL + "" + NL + "import junit.framework.Assert;" + NL + "import java.util.*;" + NL + "import org.junit.Test;" + NL + "import program.ShapeClassifier;" + NL + "" + NL + "" + NL + "public class ";
  protected final String TEXT_3 = " {" + NL + "\tShapeClassifier c = new ShapeClassifier();" + NL + "\t" + NL + "\t";
  protected final String TEXT_4 = NL + "\t" + NL + "\t@Test" + NL + "\tpublic void test";
  protected final String TEXT_5 = "(){ " + NL + "\t\tString output = c.evaluateGuess(\"";
  protected final String TEXT_6 = "\");" + NL + "\t\tSystem.out.println(\"test";
  protected final String TEXT_7 = "\" + output);" + NL + "\t\t" + NL + "\t\t";
  protected final String TEXT_8 = NL + "\t\t\tString act = null;\t" + NL + "\t\t\tif (output.startsWith(\"Yes\")) {" + NL + "\t\t\t\tact = \"Yes\";" + NL + "\t\t\t}else if(output.startsWith(\"No\")) {" + NL + "\t\t\t\tact = \"No\";" + NL + "\t\t\t}" + NL + "\t\t\t" + NL + "\t\t\tAssert.assertEquals(\"";
  protected final String TEXT_9 = "\", act);" + NL + "\t\t";
  protected final String TEXT_10 = NL + "\t}" + NL + "\t" + NL + "\t";
  protected final String TEXT_11 = NL + "}";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(((Object[])argument)[3]);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(((Object[])argument)[0]);
    stringBuffer.append(TEXT_3);
    
		for(int i=0;i<((List<String>)((Object[])argument)[1]).size();i++){
	
    stringBuffer.append(TEXT_4);
    stringBuffer.append(i);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(((List<String>)((Object[])argument)[1]).get(i));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(i);
    stringBuffer.append(TEXT_7);
     
		String expected = ((List<String>)((Object[])argument)[2]).get(i); 
	
		if (expected!=null){
		
    stringBuffer.append(TEXT_8);
    stringBuffer.append(expected);
    stringBuffer.append(TEXT_9);
    
		}
		
    stringBuffer.append(TEXT_10);
    }
    stringBuffer.append(TEXT_11);
    return stringBuffer.toString();
  }
}
